import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [{
      path: 'dashboard',
      name: 'Dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: { title: '首页', icon: 'dashboard' }
    }]
  },
  {
    path: '/center',
    name:'center',
    component: Layout,
    hidden: true,
    children: [{
      path: 'center',
      name: 'Center',
      component: () => import('@/views/pages/center/index'),
      meta: { title: '个人中心', icon: 'el-icon-user' }
    }]
  },
  {
    path: '/skill',
    name:'skill',
    component: Layout,
    redirect:'/skill/list',
    alwaysShow: true,
    meta:{title:'技能',icon:'form'},
    children: [
        {
          path: 'list',
          name: 'list',
          component: () => import('@/views/pages/skill/list/index'),
          meta: { title: '我的技能', icon: 'form' }
        }
    ]
  },
  // {
  //   path: '/scene',
  //   component: Layout,
  //   redirect:'',
  //   alwaysShow: true,
  //   name:'scene',
  //   meta:{title:'场景',icon:'form'},
  //   children: [
  //       {
  //         path: 'test',
  //         name: 'test',
  //         component: () => import('@/views/pages/scene/test/index'),
  //         meta: { title: '场景测试', icon: 'form' }
  //       },
  //       {
  //         path: 'session-log',
  //         name: 'session-log',
  //         component: () => import('@/views/pages/scene/session-log/index'),
  //         meta: { title: '对话日志', icon: 'form' }
  //       },
  //       {
  //         path: 'session-scene',
  //         name: 'session-scene',
  //         component: () => import('@/views/pages/scene/session-scene/index'),
  //         meta: { title: '对话场景', icon: 'form' }
  //       }
  //   ]
  // },
  {
    path: '/knowledge-base',
    component: Layout,
    redirect:'/knowledge-base/list',
    alwaysShow: true,
    name:'knowledge-base',
    meta:{title:'知识库',icon:'form'},
    children: [
        {
          path: 'list',
          name: 'list',
          component: () => import('@/views/pages/knowledge-base/list/index'),
          meta: { title: '我的知识库', icon: 'form' }
        }
    ]
  },
  // {
  //   path: '/staff',
  //   component: Layout,
  //   children: [{
  //     path: 'birthday',
  //     name: 'Birthday',
  //     component: () => import('@/views/staff-birthday/index'),
  //     meta: { title: '员工生日祝福', icon: 'form' }
  //   }]
  // },
  
  // {
  //   path: '/system',
  //   component: Layout,
  //   redirect: '/system/lineAreaStation',
  //   alwaysShow: true, // will always show the root menu
  //   name: 'system',
  //   meta: {
  //     title: '系统管理',
  //     icon: 'form'
  //     // roles: ['admin', 'editor'] // you can set roles in root nav
  //   },
  //   children: [
  //     {
  //       path: 'lineAreaStation',
  //       name: 'lineAreaStation',
  //       component: () => import('@/views/pages/system/org_info/index'),
  //       meta: { title: '组织机构管理', icon: 'form' }
  //     },
  //     {
  //       path: 'userInfo',
  //       name: 'userInfo',
  //       component: () => import('@/views/pages/system/user_info/index'),
  //       meta: { title: '用户管理', icon: 'form' }
  //     },
  //     {
  //       path: 'roleInfo',
  //       name: 'roleInfo',
  //       component: () => import('@/views/pages/system/role_info/index'),
  //       meta: { title: '角色管理', icon: 'form' }
  //     },
  //     {
  //       path: 'authorityInfo',
  //       name: 'authorityInfo',
  //       component: () => import('@/views/pages/system/authority_info/index'),
  //       meta: { title: '权限管理', icon: 'form' }
  //     },
  //     {
  //       path: 'menuInfo',
  //       name: 'menuInfo',
  //       component: () => import('@/views/pages/system/menu_info/index'),
  //       meta: { title: '菜单管理', icon: 'form' }
  //     }
  //   ]
  // },
  // {
  //   path: '/xingche',
  //   component: Layout,
  //   redirect: '/xingche/yanliandengji',
  //   alwaysShow: true, // will always show the root menu
  //   name: 'xingche',
  //   meta: {
  //     title: '行车类',
  //     icon: 'form'
  //     // roles: ['admin', 'editor'] // you can set roles in root nav
  //   },
  //   children: [
  //     {
  //       path: 'yanliandengji',
  //       name: 'yanliandengji',
  //       component: () => import('@/views/pages/xingche/yanliandengji/index'),
  //       meta: { title: '演练登记', icon: 'form' }
  //     },
  //     {
  //       path: 'xingcheLog',
  //       name: 'xingcheLog',
  //       component: () => import('@/views/pages/xingche/xingche_log/index'),
  //       meta: { title: '行车日志', icon: 'form' }
  //     },
  //     {
  //       path: 'workInfo',
  //       name: 'workInfo',
  //       component: () => import('@/views/pages/xingche/work_info/index'),
  //       meta: { title: '车站值班员台账', icon: 'form' }
  //     },
  //     {
  //       path: 'diaocheDriverWorkLog',
  //       name: 'diaocheDriverWorkLog',
  //       component: () => import('@/views/pages/xingche/diaoche_driver_work_log/index'),
  //       meta: { title: '调车司机工作日志', icon: 'form' }
  //     },
  //     // {
  //     //   path: 'enterExitLog',
  //     //   name: 'enterExitLog',
  //     //   component: () => import('@/views/pages/xingche/enter_exit_log/index'),
  //     //   meta: { title: '人员进出登记表', icon: 'form' }
  //     // },
  //     {
  //       path: 'beforeStationCheckRecord',
  //       name: 'beforeStationCheckRecord',
  //       component: () => import('@/views/pages/xingche/before_station_check_record/index'),
  //       meta: { title: '车站运营前检查记录表', icon: 'form' }
  //     },
  //     {
  //       path: 'stationMemberWorkLog',
  //       name: 'stationMemberWorkLog',
  //       component: () => import('@/views/pages/xingche/station_member_work_log/index'),
  //       meta: { title: '车站值班员工作日志', icon: 'form' }
  //     }
  //   ]
  // },
  // {
  //   path: '/manage',
  //   component: Layout,
  //   redirect: '/manage/meetingRecord',
  //   alwaysShow: true, // will always show the root menu
  //   name: 'manage',
  //   meta: {
  //     title: '管理类',
  //     icon: 'form'
  //     // roles: ['admin', 'editor'] // you can set roles in root nav
  //   },
  //   children: [
  //     {
  //       path: 'meetingRecord',
  //       name: 'meetingRecord',
  //       component: () => import('@/views/pages/manage/meetingRecord/index'),
  //       meta: { title: '会议记录', icon: 'form' }
  //     },
  //     {
  //       path: 'stationGoodsBorrow',
  //       name: 'stationGoodsBorrow',
  //       component: () => import('@/views/pages/manage/stationGoodsBorrow/index'),
  //       meta: { title: '车站物品/钥匙借用登记表', icon: 'form' }
  //     },
  //     {
  //       path: 'stationKeyManagement',
  //       name: 'stationKeyManagement',
  //       component: () => import('@/views/pages/manage/stationKeyManagement/index'),
  //       meta: { title: '车站钥匙管理表', icon: 'form' }
  //     },
  //     {
  //       path: 'selfCheckRecord',
  //       name: 'selfCheckRecord',
  //       component: () => import('@/views/pages/manage/selfCheckRecord/index'),
  //       meta: { title: '自查报告', icon: 'form' }
  //     },
  //     {
  //       path: 'schedulingPlanClass',
  //       name: 'schedulingPlanClass',
  //       component: () => import('@/views/pages/manage/schedulingPlanClass/index'),
  //       meta: { title: '排班表', icon: 'form' }
  //     },
  //     {
  //       path: 'adjustClass',
  //       name: 'adjustClass',
  //       component: () => import('@/views/pages/manage/adjustClass/index'),
  //       meta: { title: '调班表', icon: 'form' }
  //     },
  //     {
  //       path: 'jobEvaluation',
  //       name: 'jobEvaluation',
  //       component: () => import('@/views/pages/manage/jobEvaluation/index'),
  //       meta: { title: '岗位评估', icon: 'form' }
  //     },
  //     {
  //       path: 'jobEvaluationManage',
  //       name: 'jobEvaluationManage',
  //       component: () => import('@/views/pages/manage/jobEvaluationManage/index'),
  //       meta: { title: '岗位评估配置管理', icon: 'form' }
  //     },
  //     {
  //       path: 'stationLeaderWorkLog',
  //       name: 'stationLeaderWorkLog',
  //       component: () => import('@/views/pages/manage/stationLeaderWorkLog/index'),
  //       meta: { title: '车站值班站长工作日志', icon: 'form' }
  //     },
  //     {
  //       path: '/materials',
  //       name: 'materials',
  //       component: () => import('@/views/pages/manage/materials/index'),
  //       meta: {
  //         title: '物资类',
  //         icon: 'form'
  //         // roles: ['admin', 'editor'] // you can set roles in root nav
  //       },
  //       children:[
  //         {
  //           path: 'goodsManagementForm',
  //           name: 'goodsManagementForm',
  //           component: () => import('@/views/pages/manage/materials/goodsManagementForm/index'),
  //           meta: { title: '物资管理表', icon: 'form' }
  //         },
  //         {
  //           path: 'faultGoodsCheckInForm',
  //           name: 'faultGoodsCheckInForm',
  //           component: () => import('@/views/pages/manage/materials/faultGoodsCheckInForm/index'),
  //           meta: { title: '故障物资登记表', icon: 'form' }
  //         },
  //         {
  //           path: 'goodsRequirementForm',
  //           name: 'goodsRequirementForm',
  //           component: () => import('@/views/pages/manage/materials/goodsRequirementForm/index'),
  //           meta: { title: '物资需求表', icon: 'form' }
  //         },
  //         {
  //           path: 'goodsRequirementSummaryForm',
  //           name: 'goodsRequirementSummaryForm',
  //           component: () => import('@/views/pages/manage/materials/goodsRequirementSummaryForm/index'),
  //           meta: { title: '物资需求汇总表', icon: 'form' }
  //         },
  //         {
  //           path: 'goodsSignForCheckInForm',
  //           name: 'goodsSignForCheckInForm',
  //           component: () => import('@/views/pages/manage/materials/goodsSignForCheckInForm/index'),
  //           meta: { title: '物品签收登记表', icon: 'form' }
  //         },
  //         {
  //           path: 'goodsPandianRecord',
  //           name: 'goodsPandianRecord',
  //           component: () => import('@/views/pages/manage/materials/goodsPandianRecord/index'),
  //           meta: { title: '物资盘点记录表', icon: 'form' }
  //         },
  //         {
  //           path: 'goodsUsrConsumeForm',
  //           name: 'goodsUsrConsumeForm',
  //           component: () => import('@/views/pages/manage/materials/goodsUsrConsumeForm/index'),
  //           meta: { title: '物资领用、消耗登记表', icon: 'form' }
  //         },
  //         {
  //           path: 'goodsYearsStatisticForm',
  //           name: 'goodsYearsStatisticForm',
  //           component: () => import('@/views/pages/manage/materials/goodsYearsStatisticForm/index'),
  //           meta: { title: '部门年度物资领用、消耗、库存统计表', icon: 'form' }
  //         }
  //       ]
  //     },
  //   ]
  // },
  // {
  //   path: '/service',
  //   component: Layout,
  //   redirect: '/service/stationDailyHealthCheckTable',
  //   alwaysShow: true, // will always show the root menu
  //   name: 'service',
  //   meta: {
  //     title: '服务类',
  //     icon: 'form'
  //     // roles: ['admin', 'editor'] // you can set roles in root nav
  //   },
  //   children: [
  //     {
  //       path: 'stationDailyHealthCheckTable',
  //       name: 'stationDailyHealthCheckTable',
  //       component: () => import('@/views/pages/service/stationDailyHealthCheckTable/index'),
  //       meta: { title: '车站日常保洁质量验收表', icon: 'form' }
  //     },
  //     {
  //       path: 'passengerLostThingsRegister',
  //       name: 'passengerLostThingsRegister',
  //       component: () => import('@/views/pages/service/passengerLostThingsRegister/index'),
  //       meta: { title: '乘客遗失物品登记', icon: 'form' }
  //     },
  //     {
  //       path: 'labelAndFaultManage',
  //       name: 'labelAndFaultManage',
  //       component: () => import('@/views/pages/service/labelAndFaultManage/index'),
  //       meta: { title: '标识标贴故障破损管理', icon: 'form' }
  //     },
  //     {
  //       path: 'scenePassengersTransactionStatisticalTable',
  //       name: 'scenePassengersTransactionStatisticalTable',
  //       component: () => import('@/views/pages/service/scenePassengersTransactionStatisticalTable/index'),
  //       meta: { title: '现场乘客事务统计表', icon: 'form' }
  //     },
  //     {
  //       path: 'volunteerServiceRecord',
  //       name: 'volunteerServiceRecord',
  //       component: () => import('@/views/pages/service/volunteerServiceRecord/index'),
  //       meta: { title: '志愿者服务记录', icon: 'form' }
  //     },
  //     {
  //       path: 'ReplyCAL',
  //       name: 'ReplyCAL',
  //       component: () => import('@/views/pages/service/ReplyCAL/index'),
  //       meta: { title: '答复口径', icon: 'form' }
  //     },
  //     {
  //       path: '/passengersIdea',
  //       name: 'passengersIdea',
  //       component: () => import('@/views/pages/service/passengersIdea/index'),
  //       meta: {
  //         title: '乘客表扬、投诉、建议',
  //         icon: 'form'
  //         // roles: ['admin', 'editor'] // you can set roles in root nav
  //       },
  //       children: [
  //         {
  //           path: 'passengersIdeaStatisticalView',
  //           name: 'passengersIdeaStatisticalView',
  //           component: () => import('@/views/pages/service/passengersIdea/passengersIdeaStatisticalView/index'),
  //           meta: { title: '乘客表扬、投诉、建议统计视图', icon: 'form' },
  //         },
  //         {
  //           path: 'passengersIdeaStatisticalTable',
  //           name: 'passengersIdeaStatisticalTable',
  //           component: () => import('@/views/pages/service/passengersIdea/passengersIdeaStatisticalTable/index'),
  //           meta: { title: '乘客表扬、投诉、建议统计', icon: 'form' },
  //         }
  //       ]
  //     }
  //   ]
  // },
]

/**
 * 需要动态添加的路由
 */
export const asyncRoutes = [
  // {
  //   path: '/system',
  //   component: Layout,
  //   redirect: '/system/idInfo',
  //   alwaysShow: true,
  //   name: 'system',
  //   meta: {
  //     title: '系统',
  //     icon: 'form'
  //   },
  //   children: [
  //     {
  //       path: 'idInfo',
  //       name: 'idInfo',
  //       component: () => import('@/views/pages/system/id_info/index'),
  //       meta: { title: '账号管理', icon: 'form' }
  //     },
  //     {
  //       path: 'systemLog',
  //       name: 'systemLog',
  //       component: () => import('@/views/pages/system/system_log/index'),
  //       meta: { title: '系统日志', icon: 'form' }
  //     },
  //     {
  //       path: 'roleInfo',
  //       name: 'roleInfo',
  //       component: () => import('@/views/pages/system/role_info/index'),
  //       meta: { title: '角色管理', icon: 'form' }
  //     },
  //     {
  //       path: 'passwordSetting',
  //       name: 'passwordSetting',
  //       component: () => import('@/views/pages/system/password_setting/index'),
  //       meta: { title: '密码设置', icon: 'form' }
  //     },
  //     {
  //       path: 'menuInfo',
  //       name: 'menuInfo',
  //       component: () => import('@/views/pages/system/menu_info/index'),
  //       meta: { title: '菜单管理', icon: 'form' }
  //     }
  //   ]
  // },
  // {
  //   path: '/skill',
  //   name:'skill',
  //   component: Layout,
  //   redirect:'/skill/list',
  //   alwaysShow: true,
  //   meta:{title:'技能',icon:'form'},
  //   children: [
  //       {
  //         path: 'list',
  //         name: 'list',
  //         component: () => import('@/views/pages/skill/list/index'),
  //         meta: { title: '我的技能', icon: 'form' }
  //       }
  //   ]
  // },
  // {
  //   path: '/scene',
  //   component: Layout,
  //   redirect:'',
  //   alwaysShow: true,
  //   name:'scene',
  //   meta:{title:'场景',icon:'form'},
  //   children: [
  //       {
  //         path: 'test',
  //         name: 'test',
  //         component: () => import('@/views/pages/scene/test/index'),
  //         meta: { title: '场景测试', icon: 'form' }
  //       },
  //       {
  //         path: 'session-log',
  //         name: 'session-log',
  //         component: () => import('@/views/pages/scene/session-log/index'),
  //         meta: { title: '对话日志', icon: 'form' }
  //       },
  //       {
  //         path: 'session-scene',
  //         name: 'session-scene',
  //         component: () => import('@/views/pages/scene/session-scene/index'),
  //         meta: { title: '对话场景', icon: 'form' }
  //       }
  //   ]
  // },
  // {
  //   path: '/knowledge-base',
  //   component: Layout,
  //   redirect:'/knowledge-base/list',
  //   alwaysShow: true,
  //   name:'knowledge-base',
  //   meta:{title:'知识库',icon:'form'},
  //   children: [
  //       {
  //         path: 'list',
  //         name: 'list',
  //         component: () => import('@/views/pages/knowledge-base/list/index'),
  //         meta: { title: '我的知识库', icon: 'form' }
  //       }
  //   ]
  // },
  // // 404 page must be placed at the end !!!
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
